\usepackage{algorithm,algorithmic,ifthen}
\usepackage{listings}


\floatname{algorithm}{算法}
\newcommand\forthsection[1]{\noindent \S #1}
\renewcommand{\algorithmicrequire}{ \textbf{初始化:}} %Use Input in the format of Algorithm  
\renewcommand{\algorithmicensure}{ \textbf{输出:}} %UseOutput in the format of Algorithm
\renewcommand\theequation{\arabic{chapter}-\arabic{equation}}
\renewcommand{\thealgorithm}{\arabic{chapter}-\arabic{algorithm}}


%=================================== Code Style ==============================%
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstset{
    aboveskip=3mm,
    belowskip=3mm,
    showstringspaces=false,
    columns=flexible,
    basicstyle={\normalsize\ttfamily},
    numbers=left,
    frame=L,
    numberstyle=\tiny\color{mygray},
    keywordstyle=\color{blue},
    commentstyle=\color{mygreen},
    stringstyle=\color{mymauve},
    breaklines=true,
    breakatwhitespace=true,
    tabsize=3,
    framextopmargin=2pt,framexbottommargin=2pt,abovecaptionskip=-3pt,belowcaptionskip=3pt,  
    xleftmargin=1em, % 设定listing左右的空白
}
%=================================== Code Style ==============================%